#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define all(x) (x).begin(),(x).end()
typedef long long ll;

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<VI> VVI;

typedef pair<int,int> PII;
typedef vector<PII> VPII;
#define X first
#define Y second
#define mp make_pair

#define two(x) (1<<(x))
#define twoll(x) ((long long)1<<(x))
#define contain(s,x) (((s)&two(x))!=0)
#define containll(s,x) (((s)&twoll(x))!=0)

#define db(a) cout << #a << "=" << a << " "
#define dbn cout << endl
#define sqr(x) (x)*(x)

string STR(int n) { char tmp[20]; sprintf(tmp,"%d",n); return tmp; }
int INT(string s) { return atoi(s.c_str()); }
template <class Ty, class Tx> Ty to(const Tx &x) { Ty y; stringstream ss; ss<<x; ss>>y; return y; }

const int INF = 1000000007;
const double EPS = 1e-10;

bool check(VS vs) {
	set<string> S;
	for (int i = 0; i < vs.size(); ++i) {
		if (vs[i].length() == 0 || S.count(vs[i]))
			return 1;
		S.insert(vs[i]);
	}
	return 0;
}

int main() {
#define SUBMIT 1
#if !SUBMIT
	freopen("DATA.in", "rt", stdin);
	freopen("DATA.ou", "wt", stdout);
#endif

	int n;
	while (cin >> n) {
		if (n == 0) break;
		string str;
		VS vs;
		for (int i = 0; i < n; ++i) {
			cin >> str;
			vs.push_back(str);
		}
		int cnt = 0;
		while (true) {
			if (check(vs)) break;
			++cnt;
			for (int i = 0; i < vs.size(); ++i)
				vs[i] = vs[i].substr(1);
		}
		cout << cnt-1 << endl;
	}

	return 0;
}





















